package com.sc.teacher.utils;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse;

/**
 * @Auther: 段力博
 * @Date: 2020/9/24 23:00
 * @Description: 根据视频id获取播放凭证
 */

public class PlayAuthUtil {

    public static String getPlayAuthByVideoId(String videoId){

        try {
            DefaultAcsClient client = InitObject.initVodClient("LTAI4G1wEFciZb99oaB18kSa", "ju9sfURuo6gsQcySWCPEZxlSZx8nXI");

            GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
            GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();

            request.setVideoId(videoId);
            response = client.getAcsResponse(request);
            return response.getPlayAuth();
        } catch (ClientException e) {
            e.printStackTrace();
            return null;
        }

    }
}
